package chapter8.quarter4;

import javax.swing.*;
import java.awt.*;

public class BoxLayoutDemo {
    private JFrame frame;
    private JPanel pv,ph;

    public static void main(String[] args) {
        BoxLayoutDemo that=new BoxLayoutDemo();
        that.go();
    }

    public void go() {
        frame=new JFrame("box layout example");
        Container contentPane=frame.getContentPane();
        pv=new JPanel();
        pv.setLayout(new BoxLayout(pv,BoxLayout.Y_AXIS));
        pv.add(new JLabel("first"));
        pv.add(new JLabel("second"));
        pv.add(new JLabel("third"));
        contentPane.add(pv,BorderLayout.CENTER);
        ph=new JPanel();
        ph.setLayout(new BoxLayout(ph,BoxLayout.X_AXIS));
        ph.add(new JLabel("yes"));
        ph.add(new JLabel("no"));
        ph.add(new JLabel("cancel"));
        contentPane.add(ph,BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
